import java.text.*;
import java.util.*;
import java.io.*;

abstract class MarkovModelAlgo {

  MarkovModel mm;

  Object x[];

  public MarkovModelAlgo ( MarkovModel mm, Object x[] ) { this.mm = mm; this.x = x; }

  static double logplus(double plog, double qlog) {
    double max, diff;
    if (plog > qlog) {
      if (qlog == Double.NEGATIVE_INFINITY) return plog;
      else { max = plog; diff = qlog - plog; } 
    } else {
      if (plog == Double.NEGATIVE_INFINITY) return qlog;
      else { max = qlog; diff = plog - qlog; }
    }
    return max + (diff < -37 ? 0 : Math.log(1 + Math.exp(diff)));
  }

}
